﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UFSoft.UBF.Business;
using UFSoft.UBF.Eventing;
using UFIDA.U9.SM.Ship;
using UFIDA.U9.PM.PO;
using UFSoft.UBF.PL;
using UFIDA.U9.PM.Rcv;
using UFIDA.U9.SM.RMA;
using UFIDA.U9.SM.SO;
using UFIDA.U9.CBO.SCM.Customer;


namespace UFIDA.U9.Cust.U9Demo.PlugBE
{
    /// <summary>
    /// 培训代码示例
    /// 发货单
    /// 审核成功后，反写其他单据的值
    /// </summary>
    class ShipUpdatedExtend : IEventSubscriber
    {
        //配置XX.sub.xml文件放置到portal/bin下，dll文件放置到portal/ApplicationServer/Libs下
        public void Notify(params object[] args)
        {
            if (args != null && args.Length != 0 && args[0] is EntityEvent)
            {
                BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
                UFIDA.U9.SM.Ship.Ship ship = key.GetEntity() as UFIDA.U9.SM.Ship.Ship;
                if (ship == null)
                    return;
                if (ship.SrcDocType.Value != 1)//不是来源销售订单不需要处理
                    return;
                //审核成功后，反写其他单据的值
                if (ship.Status == ShipStateEnum.Approved &&
                    ship.OriginalData.Status == ShipStateEnum.Approving)
                {
                    using (ISession session = Session.Open())
                    {
        
                        session.Commit();
                    }
                  
                }
                
                
            }
        }

     
    }
}
